import { execa } from 'execa'
import * as prettier from 'prettier'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'

const __filenameNew = fileURLToPath(import.meta.url)
const __dirnameNew = dirname(__filenameNew)

async function release1() {
  const file_content = `
    export const version = {
      '@hs-admin/api': '0.0.11',
      '@react-admin/pro-components': '0.0.81',
      '@react-admin/pro-form': '0.0.10',
      '@react-admin/pro-scroll-select': '0.0.7',
      '@react-admin/pro-spin': '0.0.24',
      '@react-admin/pro-table-page': '0.0.26',
      '@react-admin/pro-upload': '0.0.9',
      '@react-admin/pro-utils': '0.0.16'
    }
  `
  try {
    const res = await prettier.format(file_content, { parser: 'typescript', semi: false, singleQuote: true, trailingComma: 'none' })
    console.log('[ res ] >', res)
  } catch (error) {
    console.log('[ lerna error ] >', error)
  }
}

async function release() {
  try {
    console.log('[ lerna release ] >')
    const res = await execa('lerna', ['version', 'patch'], { stdio: 'inherit' })
    console.log('[ res ] >', res)
  } catch (error) {
    console.log('[ lerna error ] >', error)
  }
}

release1()
